package com.cskaoyan.crud;

import com.cskaoyan.bean.Student;
import com.cskaoyan.mapper.StudentMapper;
import com.cskaoyan.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

/**
 * 创建日期: 2022/11/23 10:12
 *
 * @author ciggar
 */
public class AddDemo {

    public static void main(String[] args) {

        // 1. 获取SqlSession
        SqlSession sqlSession = MybatisUtils.getSqlSession();


        Student student = new Student();
        student.setId(5001);
        student.setName("C罗");
        student.setClazz("七班");
        int affectedRows = sqlSession.insert("com.cskaoyan.mapper.StudentMapper.insertStudent2", student);

        System.out.println(affectedRows);

//        // 2. 获取接口的代理对象
//        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
//
//
//        // 3. 执行接口中的方法
//        Student student = new Student();
//        student.setId(4001);
//        student.setName("梅西");
//        student.setClazz("六班");
//
//
//        int affectedRows = studentMapper.insertStudent2(student);
//
//        System.out.println("affectedRows:" + affectedRows);


    }

}
